package model.gamemenu;

import java.util.ArrayList;

public class ItemList {
	private int currentItem;
	private ArrayList<MenuItem> items;
	
	/** Constructs a new item list */
	public ItemList() {
		this.items = new ArrayList<MenuItem>();
	}
	
	/** Returns an item in the list */
	public MenuItem getItem(int index) {
		return this.items.get(index);
	}
	
	/** Returns the selected item */
	public MenuItem getCurrentItem() {
		return this.items.get(currentItem);
	}
	
	/** Returns the size of the list */
	public int getSize() {
		return this.items.size();
	}
	
	/** Adds an item to the list */
	public void add(MenuItem item) {
		this.items.add(item);
	}

	/** Scrolls up through the list */
	public void scrollUp() {
		if (this.currentItem != 0) {
			this.items.get(currentItem).setSelected(false);
			this.currentItem--;
			this.items.get(currentItem).setSelected(true);
		}
	}
	
	/** Scrolls down though the list */
	public void scrollDown() {
		if (this.currentItem < this.items.size() - 1) {
			this.items.get(currentItem).setSelected(false);
			this.currentItem++;
			this.items.get(currentItem).setSelected(true);
		}
	}
}